package jsr166.contrib.uncontended;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;

/**
 * This class provides a read write lock that throws  UnexpectedConcurrentAccessException if an attempt is made to acquire a read
 * or write lock by any thread other than the one that created the ThreadConfinedReadWriteLock.
 * @author pugh
 *
 */
public class ThreadConfinedReadWriteLock implements ReadWriteLock {

    public ThreadConfinedReadWriteLock(Thread t) {
        lock = new ThreadConfinedLock(t);
    }
    public ThreadConfinedReadWriteLock() {
        lock = new ThreadConfinedLock();
    }
    final Lock lock;
    
    public Lock readLock() {
        return lock;
    }

    public Lock writeLock() {
        return lock;
    }

}
